# frozen_string_literal: true

require "spec_helper"

RSpec.describe "CLI", "appraisal generate" do
  it "generates the gemfiles" do
    build_gemfile <<-GEMFILE
      source "https://rubygems.org"

      gem "appraisal", :path => "#{PROJECT_ROOT}"
    GEMFILE

    build_appraisal_file <<-APPRAISAL
      appraise '1.0.0' do
        gem 'dummy', '1.0.0'
      end

      appraise '1.1.0' do
        gem 'dummy', '1.1.0'
      end
    APPRAISAL

    run "appraisal generate"

    expect(file("gemfiles/1.0.0.gemfile")).to be_exists
    expect(file("gemfiles/1.1.0.gemfile")).to be_exists
    expect(content_of("gemfiles/1.0.0.gemfile")).to eq <<-GEMFILE.strip_heredoc
      # This file was generated by Appraisal

      source "https://rubygems.org"

      gem "appraisal", :path => "#{PROJECT_ROOT}"
      gem "dummy", "1.0.0"
    GEMFILE
  end
end
